import { Queryable } from '~/core/dsl';
import { SensitiveLocalStorageRule, FindLocalStoragePassword, FindLocalStoragePasswordThroughDataFlow, FindLogSensitiveInfo, FindUnsafeRedirect, FindXSS, FindInsecureHttpRequest, FindInsecureHttpRequestThroughDataflow, FindExcessiveSQLPrivileges, FindUnsafeFilePath, FindLocalStoragePasswordThroughDataFlow2, FindUnsafeFilePath2, FindLogSensitiveInfo2, FindMathRandom , FindUnsafeMacHash, FindXSS2, FindExcessiveSQLPrivileges2, FindJsonParseProto, FindUnsafeRouter, FindEval, FindUnsafeSql, FindCallingDeprecatedDecorators} from './native';
import { DslRule } from 'qvog-dsl';
import SensitiveLocalStorageDslSimple from '~/rule/dsl/SensitiveLocalStorageDslSimple';
import FindUnsafeRedirectDsl from './dsl/FindUnsafeRedirectDsl';
import AvoidFrequentStateUpdate from './dsl/AvoidFrequentStateUpdate';
import FindUnsafeFilePathDsl from './dsl/FindUnsafeFilePathDsl';
import SensitiveLocalStorageDsl from './dsl/SensitiveLocalStorageDsl';
import LoggingSensitiveInfoDsl from './dsl/LoggingSensitiveInfoDsl';
import MatchTest from 'test/core/rules/Match';
import WhenTest from 'test/core/rules/When';
import ExistFlow from 'test/core/rules/ExistFlow';

type NativeRuleOption = [string, Queryable, 'on' | 'off'];
type DslRuleOption = [DslRule<Queryable>, 'on' | 'off'];

export const NativeRules: NativeRuleOption[] = [
    [SensitiveLocalStorageRule[0], SensitiveLocalStorageRule, 'off'],
    [FindLocalStoragePassword[0], FindLocalStoragePassword, 'off'],
    [FindLocalStoragePasswordThroughDataFlow[0], FindLocalStoragePasswordThroughDataFlow, 'off'],
    [FindLogSensitiveInfo[0], FindLogSensitiveInfo, 'off'],
    [FindXSS[0], FindXSS, 'off'],
    [FindExcessiveSQLPrivileges[0], FindExcessiveSQLPrivileges, 'off'],
    [FindUnsafeFilePath[0], FindUnsafeFilePath, 'off'],
    
    [FindUnsafeRedirect[0], FindUnsafeRedirect, 'off'],
    [FindInsecureHttpRequest[0], FindInsecureHttpRequest, 'off'],
    [FindInsecureHttpRequestThroughDataflow[0], FindInsecureHttpRequestThroughDataflow, 'off'],
    [FindLocalStoragePasswordThroughDataFlow2[0], FindLocalStoragePasswordThroughDataFlow2, 'off'],
    [FindUnsafeFilePath2[0], FindUnsafeFilePath2, 'off'],
    [FindLogSensitiveInfo2[0], FindLogSensitiveInfo2, 'off'],
    [FindMathRandom[0], FindMathRandom, 'off'],
    [FindUnsafeMacHash[0], FindUnsafeMacHash, 'off'],
    [FindXSS2[0], FindXSS2, 'off'],
    [FindExcessiveSQLPrivileges2[0], FindExcessiveSQLPrivileges2, 'off'],
    [FindJsonParseProto[0], FindJsonParseProto, 'off'],
    [FindUnsafeRouter[0], FindUnsafeRouter, 'off'],
    [FindEval[0], FindEval, 'off'],
    [FindUnsafeSql[0], FindUnsafeSql, 'off'],
    [FindCallingDeprecatedDecorators[0], FindCallingDeprecatedDecorators, 'off'],
];
export const DslRules: DslRuleOption[] = [
    [SensitiveLocalStorageDslSimple, 'off'],
    [FindUnsafeRedirectDsl, 'off'],
    [AvoidFrequentStateUpdate, 'off'],
    [FindUnsafeFilePathDsl, 'off'],
    [SensitiveLocalStorageDsl, 'on'],
    [LoggingSensitiveInfoDsl, 'off'],

    [MatchTest, 'off'],
    [WhenTest, 'off'],
    [ExistFlow, 'off'],
];
